Despite advances in computer vision, image processing, and machine learning, recognizing visual objects remains a task where computers fail in comparison with the capabilities of human. Recognizing an object from an image not only requires recognizing the image in a scene but also recognizing objects in various positions, in different settings, and with slight variations. For example, to recognize a chair, the innate properties that make a chair a chair must be understood. This is a simple task for a human. Computers struggle to deal with the vast variety of types of chairs and the situations in which a chair may be present. The problem is even more challenging when considering the problem of detecting multiple objects in a scene. Models exist for object recognition such as convolution neural networks, HMAX models, Slow Feature Analysis (SFA), and Hierarchical Temporal Memory (HTM), but these approaches fail to achieve results near ideal recognition performance. Object detection is more broadly a problem of pattern detection. Pattern detection is a problem in other fields and mediums outside of image processing such as speech recognition, natural language processing, and other fields. Additionally, the inverse of pattern recognition is generation. Generating patterns have similar problems, and existing approaches similarly fail to produce satisfactory results. Thus, there is a need in the artificial intelligence field to create a new and useful system and method with improved object recognition (or “inference”) and generation. This invention, which is designated a recursive cortical network, provides such system and method.